package com.asistencia.businness;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.asistencia.dao.interfaces.EnrollmentDao;
import com.asistencia.domain.Enrollment;

@Service
public class EnrollmentBusiness {

	@Autowired
	private EnrollmentDao enrollmentDao;

	public List<Enrollment> listByCourseSemester(Integer idCourse,
			Integer idSemester) {
		try {
			enrollmentDao.listByCourseSemester(idCourse, idSemester);
			List<Enrollment> lstEnro = enrollmentDao.listByCourseSemester(
					idCourse, idSemester);
			return lstEnro;
		} catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public List<Enrollment> listByStudentSemester(Integer idStudent,
			Integer idSemester) {
		try {
			enrollmentDao.listByStudentSemester(idStudent, idSemester);
			List<Enrollment> lstSemes = enrollmentDao.listByStudentSemester(
					idStudent, idSemester);
			return lstSemes;
		} catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public List<Enrollment> listByStudent(Integer idStudent) {
		try {
			enrollmentDao.listByStudent(idStudent);
			List<Enrollment> lstStudent = enrollmentDao
					.listByStudent(idStudent);
			return lstStudent;
		} catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public List<Enrollment> listByDate(String date) {
		try {
			enrollmentDao.listByDate(date);
			List<Enrollment> lstDate = enrollmentDao.listByDate(date);
			return lstDate;
		} catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}

	public List<Enrollment> listBetweenDates(String date, String date1) {
		try {
			enrollmentDao.listBetweenDates(date, date1);
			List<Enrollment> lstBet = enrollmentDao.listBetweenDates(date,
					date1);
			return lstBet;
		} catch (DataAccessException e) {
			e.printStackTrace();
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
